package edu.hit.mylib.controller;

import edu.hit.mylib.dao.UserInfoMapper;
import edu.hit.mylib.pojo.Userinfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class JsonTest {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @CrossOrigin /*解决跨域问题*/
    @GetMapping("/getjson")
    public List<Userinfo> getList(){
//        StringBuffer ans = new StringBuffer();
        List<Userinfo> userinfos = userInfoMapper.selectList(null);
//        for (Userinfo userinfo : userinfos) {
//            ans.append(userinfo.toString());
//        }
//        return ans.toString();
        return userinfos;
    }
}
